<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>配置文件修改</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/oksub.css">
</head>
<body>
<div class="ok-body layui-container ">
    <form class="layui-form layui-form-pane ok-form">

        <div class="layui-row layui-col-space10">
                <div class="layui-col-md8 ">
                    <div class="layui-form-item">
                        <label class="layui-form-label">IP</label>
                        <div class="layui-input-block">
                            <input type="text" name="ip" placeholder="PLC设备IP" th:value="${ip}" autocomplete="off" class="layui-input"
                                   lay-verify="required">
                        </div>
                    </div>
                </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">DB地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="dbAddress" placeholder="填写DB 空间位置" th:value="${dbAddress}" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">PLC 类型</label>
                    <div class="layui-input-block">
                        <label>
                            <select name="plcType"  th:value="${plcType}">
                                <option  value="">请选择对应的类型</option>
                                <option   value="S200"  th:selected="${plcType == 'S200'}">S200</option>
                                <option   value="S200_SMART" th:selected="${plcType == 'S200_SMART'}" >S200_SMART</option>
                                <option   value="S300" th:selected="${plcType == 'S300'}" >S300</option>
                                <option   value="S400" th:selected="${plcType == 'S400'}" >S400</option>
                                <option   value="S1200" th:selected="${plcType == 'S1200'}" >S1200</option>
                                <option   value="S1500" th:selected="${plcType == 'S1500'}" >S1500</option>
                                <option   value="828D" th:selected="${plcType == '828D'}" >828D</option>
                            </select>
                        </label>
                    </div>
                </div>
            </div>
        </div>


        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">心跳地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="heartbeatOffset" th:value="${heartbeatOffset}" placeholder="心跳地址" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">错误地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="errorOffset" th:value="${errorOffset}" placeholder="PLC错误地址" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">移动API</label>
                    <div class="layui-input-block">
                        <input type="text" name="requestMoveApi" th:value="${requestMoveApi}" placeholder="填写agv请求移动API" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md8 ">
                <div class="layui-form-item">
                    <label class="layui-form-label">完成API</label>
                    <div class="layui-input-block">
                        <input type="text" name="requestFinishApi" th:value="${requestFinishApi}" placeholder="填写agv请求完成API" autocomplete="off" class="layui-input"
                               lay-verify="required">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="add">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>
<!--js逻辑-->
<script src="/layui/layui.js"></script>
<script>
    layui.use(["element", "jquery","form", "laydate", "okLayer",'upload'], function () {
        let form = layui.form;
        let laydate = layui.laydate;
        let okLayer = layui.okLayer;
        let upload = layui.upload;
        let $ = layui.jquery;
        let layer = layui.layer;



        form.on("submit(add)", function (data) {
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });*/
            $.ajax({
                url:'/data/modifySystem',
                type:'POST',
                data: data.field,
                success: function (response) {
                    if (response.code===200){
                        layer.msg(response.msg, {
                            time: 1800 // 2秒关闭（如果不配置，默认是3秒）
                        }, function() {
                            //刷新页面
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        });
                    }else{
                        layer.msg(response.msg);
                    }
                }
            });

            return false;
        });




    });
</script>
</body>
</html>
